/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication6.ControlLayer;

/**
 *
 * @author meydlo
 */
import javaapplication6.DomainLayer.SellRecords;
import javaapplication6.DomainLayer.SellProduct;
public class SellControl {

    private SellRecords sellRecords=SellRecords.getSellRecords();
    private long idOfProduct=0;

    //
    public SellProduct createSellProduct(String name, String description, int numOfOneType, double price,double discount)
    {

        idOfProduct=idOfProduct+1;
        SellProduct sellProduct=sellRecords.createSellProduct(idOfProduct,name, description, numOfOneType, price, discount);
        return sellProduct;
    }


    //
    public void deleteSellProduct(long id)
    {
        sellRecords.deleteSellProduct(id);
    }

    //
    public SellProduct findSellProduct(long id)
    {
        return sellRecords.sellProductByID(id);
    }

    //
    public void printSellProductInfo(long id)
    {
        try{
        sellRecords.sellProductByID(id).printProductInfo();
        }
        catch(Exception e){
            sellRecords.sellProductByID(id);
        }
    }

    public void printSellProductList()
    {
        sellRecords.printSellProductList();
    }

    public SellProduct getSellProductByName(String name)
    {
        SellProduct sellProduct=sellRecords.sellProductByName(name);
        return sellProduct;
    }

}
